<%@ page language="java" errorPage="/error.jsp" pageEncoding="UTF-8" contentType="text/html; charset=utf-8" %>
<%@include file="/quick/include/common.jsp"%>
<c:set var="buttons">
    <input type="button" style="margin-right: 5px"   onclick="f_add()" value="<fmt:message key="button.add"/>"/>
    <input type="button" style="margin-right: 5px"   onclick="f_update()" value="<fmt:message key="button.update"/>"/>
    <input type="button" style="margin-right: 5px"   onclick="f_delete()" value="<fmt:message key="button.delete"/>"/>
    <input type="button" style="margin-right: 5px"   onclick="f_cancel()" value="<fmt:message key="button.cancel"/>"/>
    <input type="button" style="margin-right: 5px"   onclick="f_save()" value="<fmt:message key="button.save"/>"/>
    <input type="button" style="margin-right: 5px"   onclick="f_query()" value="<fmt:message key="button.query"/>"/>
    <input type="button" style="margin-right: 5px"   onclick="f_taskClass()" value="<fmt:message key="button.task.class"/>"/>
    <input type="button" style="margin-right: 5px"   onclick="f_print()" value="<fmt:message key="button.print.score.table"/>"/>
    <input type="button" style="margin-right: 5px"   onclick="f_printAll()" value="<fmt:message key="button.print.all.score.table"/>"/>
<c:if test='${not empty model.parentId}'>
    <input type="button" style="margin-right: 5px"   onclick="f_back()" value="<fmt:message key="button.back"/>"/>
</c:if>
</c:set>
<div id='toolbar' style="display:none">
<c:out value="${buttons}" escapeXml="false"/>
</div>
<script>
Ext.onReady(globalScope._ready);

Ext.onReady(function(){
  
  
}); 

<c:if test='${not empty model.parentId}'>
function f_back(){
   globalScope._back();
}
</c:if>

var timetableYear="<c:out value='${model.parameter.SCHOOL_YEAR}'/>";
var timetableSemester="<c:out value='${model.parameter.SCHOOL_SEMESTER}'/>";

function f_taskClass(){
  var r=globalScope.grid.get("T_TASK_COURSE").getSelectionModel().getSelected();
  if(Ext.isEmpty(r)){
    Ext.Msg.alert('WARNING','请选择数据表');
    return;
  }
  var id=r.id;
   var matrix=[["tableName","T_TASK_CLASS"],["REFID",id]];
   var form=createForm("<c:url value='/quick/quickWithParentInfo.html'/>",matrix);
   form.submit();
}

function f_print(){
  var r=globalScope.grid.get("T_TASK_COURSE").getSelectionModel().getSelected();
  if(Ext.isEmpty(r)){
    Ext.Msg.alert('WARNING','请选择课程');
    return;
  }
  var courseNo='COURSE_NO[$]'+r.get('COURSE_NO');
  var schoolYear='SCHOOL_YEAR[$]'+r.get('SCHOOL_YEAR');
  var schoolSemester='SCHOOL_SEMESTER[$]'+r.get('SCHOOL_SEMESTER');
  
  var matrix=[['jasper','/web-inf/pages/task/scoreTable.jasper'],['params',schoolYear],['params',schoolSemester],['params',courseNo]];
  var form=createForm(g_rootPath+'pdf/print.html',matrix);
  form.target="_blank";
  form.submit();
}

function f_printAll(){
  if(confirm("确认打印所有课程的成绩录入单吗?")==false){
    return;
  }
  var schoolYear='SCHOOL_YEAR[$]'+timetableYear;
  var schoolSemester='SCHOOL_SEMESTER[$]'+timetableSemester;
  
  var matrix=[['jasper','/web-inf/pages/task/scoreTable.jasper'],['params',schoolYear],['params',schoolSemester]];
  var form=createForm(g_rootPath+'pdf/print.html',matrix);
  form.target="_blank";
  form.submit();
}


function f_add(tableName){
  globalScope._add(tableName);
}

function f_update(tableName){
  globalScope._update(tableName);
}

function f_delete(tableName){
  globalScope._delete(tableName);
} 

function f_cancel(tableName){
  globalScope._cancel(tableName);
}

function f_save(tableName,url){
  globalScope._save(tableName,url);
}

function f_query(tableName){
    globalScope._query(tableName);
}
function f_gotoPage(pageNo,rowsOfPage,pageCount,rowCount,conditoin){
  globalScope._gotoPage({spanName:"g_pageSpan_<c:out value='${model.tableName}'/>",pageNo:pageNo,rowsOfPage:rowsOfPage,pageCount:pageCount,rowCount:rowCount,condition:conditoin,tableName:"<c:out value='${model.tableName}'/>"});
}
</script>
